/**
 * 
 * The MIT License
 * 
 * Copyright (c) 2008 the original author or authors.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.googlecode.gchartjava;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.googlecode.gchartjava.AxisStyle.AlignmentEnum;
import com.googlecode.gchartjava.ShapeMarker.ShapeEnum;

/**
 * 
 * @author Julien Chastang (julien.c.chastang at gmail dot com)
 */
public class ScatterChartExample {
	
	@Test
	public void example1(){
		Data d1 = new Data(10,50,30,45,65,95,20,80);
		Data d2 = new Data(20,40,40,15,85,95,80,20);
		ScatterPlotData data = new ScatterPlotData(d1,d2);
		data.setLegend("Diamond");
		Color diamondColor = new Color("FF471A");
		data.addShapeMarker(new ShapeMarker(ShapeEnum.DIAMOND,diamondColor,1,5,20));
		data.setColor(diamondColor);
		ScatterPlot chart = new ScatterPlot(data);
		chart.setSize(600, 450);
		chart.setGrid(new LineStyle(3,3,2), 20, 20);
		
		AxisInfo axisInfo = new AxisInfo(0,100);
		axisInfo.setAxisStyle(new AxisStyle(Color.WHITE,13,AlignmentEnum.CENTER));

		chart.addXAxisInfo(axisInfo);
		chart.addYAxisInfo(axisInfo);
		
		chart.setTitle("Scatter Plot",Color.WHITE,16);
		chart.setBackgroundFill(new SolidFill(new Color("2F3E3E")));
		LinearGradientFill fill = new LinearGradientFill(0,new Color("3783DB"),1);
		fill.addColorAndOffset(new Color("9BD8F5"),0);
		chart.setAreaFill(fill);
		System.out.println(chart.createURLString());
		String expectedString = "http://chart.apis.google.com/chart?cht=s&chg=20,20,3,2&chs=600x450&chxr=0,0,100|1,0,100&chxt=y,x&chxs=0,FFFFFF,13,0|1,FFFFFF,13,0&chts=FFFFFF,16&chdl=Diamond&chco=FF471A&chf=bg,s,2F3E3E|c,lg,0,3783DB,1.0,9BD8F5,0.0&chm=d,FF471A,0,1,20,0|d,FF471A,0,2,20,0|d,FF471A,0,3,20,0|d,FF471A,0,4,20,0|d,FF471A,0,5,20,0&chd=e:GagATNczpm8yMzzM,MzZmZmJm2Z8yzMMz&chtt=Scatter+Plot";
		assertEquals("Junit error", expectedString,chart.createURLString());
	}
}
